package com.lagou.mall.esflow.server.repository;

import static java.util.Optional.ofNullable;

import com.lagou.mall.esflow.server.config.ShardingJdbc;
import com.lagou.mall.esflow.server.persistence.model.ItemDO;
import java.util.Optional;
import javax.annotation.Resource;
import org.springframework.stereotype.Repository;

/**
 * @Author xiazhenyu
 * @Description
 * @Date 10:48 上午 2021/3/23
 **/
@Repository
public class ItemRepositoryImpl implements  ItemRepository{

    @Resource
    private ShardingJdbc shardingJdbc;

    @Override
    public ItemDO getItem(Long itemId) {
        ItemDO.ItemDOBuilder result = ItemDO.builder();
        Optional<Long> merchantItemIdOpt = ofNullable(itemId).filter(id -> id > 0);
        if (!merchantItemIdOpt.isPresent()) {
            return result.build();
        }
        shardingJdbc.newStatement(statement -> {
            //查询数据库，组装itemDO中的数据
        });
        return result.build();
    }

}
